﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using Silvermoon.Images;
using System.Drawing;
using Passwords.Images;
using Silvermoon.Shapes;

namespace Passwords.Controls
{
    public class PickerItem : TitleDetailsImageItem
    {
        public PickerItem()
            : base()
        {
            this.Image = SysImages.Circle;
        }

        protected override void OnLayout()
        {
            Image = IsSelected ? ImagePool.CircleCheck : SysImages.Circle;
            base.OnLayout();
        }

        protected override void LayoutShapes()
        {
            Rectangle bounds = padding.LayoutChild(ClientBounds);
            int h = bounds.Height;

            detailsShape.Visible = false;

            int y = (Height - imageShape.Height) / 2;
            imageShape.Location = Control.ScaledPoint(bounds.X, y);
            int x = Image != null ? (imageShape.Width + padding.LeftZero) : 0;
            int w = Math.Max(0, bounds.Width - x);

            int titleHeight = Title.Length > 0 ? titleShape.Font.CharHeight : 0;
            y = (Height - titleHeight) / 2;
            titleShape.Bounds = Control.ScaledRect(bounds.X + x, y, w, titleHeight);
            //            titleHeight += titleDetailsSpace;
        }

        protected override void OnTap(TapEventArgs e)
        {
            IsSelected ^= true;
            e.Handled = true;
            base.OnTap(e);
        }

    }
}
